package com.koron.css2.newProjectCenter.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.koron.css2.ServerInterface;
import com.koron.css2.newProjectCenter.bean.PjPubUpScrap;
import com.koron.css2.newProjectCenter.bean.query.PjPubUpScrapQuery;
import com.koron.css2.newProjectCenter.mapper.PjPubUpScrapMapper;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import com.koron.css2.serviceManage.utils.JsonUtils;
import com.koron.util.Constant;
import org.koron.ebs.mybatis.SessionFactory;
import org.swan.bean.MessageBean;

import java.util.List;

/**
 * @Author: 苏小龙
 * @CreateTime: 2024-12-04
 * @Description: 材料报废遗失
 * @Version: 1.0
 */
public class PjPubUpScrapList implements ServerInterface{
    @Override
    public MessageBean<?> exec(SessionFactory factory, UserInfoBean userInfo, RequestBean req) {
        try {
            PjPubUpScrapQuery pubUpInvoiceQuery = JsonUtils.objectToPojo(req.getData(),PjPubUpScrapQuery.class);
            PjPubUpScrapMapper pjPubUpInvoiceMapper= factory.getMapper(PjPubUpScrapMapper.class);
            PageHelper.startPage(pubUpInvoiceQuery.getPage(), pubUpInvoiceQuery.getPageCount());
            List<PjPubUpScrap> pubUpInvoiceList = pjPubUpInvoiceMapper.getList(pubUpInvoiceQuery);
            MessageBean<PageInfo> messageBean = MessageBean.create(Constant.MESSAGE_INT_SUCCESS, "材料报废遗失查询成功", PageInfo.class);
            messageBean.setData(new PageInfo<>(pubUpInvoiceList));
            return messageBean;
        } catch (Exception e) {
            logger.error("材料报废遗失查询失败", e);
            return MessageBean.create(Constant.MESSAGE_INT_FAIL, "材料报废遗失查询失败:", null);
        }
    }
}
